//
//  LBBuyCardetailsHeadCell.m
//  loveBeen
//
//  Created by 杨烁 on 2016/11/20.
//  Copyright © 2016年 loveBeen. All rights reserved.
//

#import "LBBuyCardetailsHeadCell.h"
#import "UITextField+DDPickerView.h"

@interface LBBuyCardetailsHeadCell ()<DDInputPickerViewDelegate>

@property (strong , nonatomic) UITextField * textField;
@end

@implementation LBBuyCardetailsHeadCell

-(void)awakeFromNib{
    
    [super awakeFromNib];
   
    
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(click)];
    
    [self addGestureRecognizer:tap];
    
    [self addPickerView];
    
}

-(void)click{
    if ([self.textField isFirstResponder]) {
        [self.textField resignFirstResponder];
        NSLog(@"1");
    }else{
    [self.textField becomeFirstResponder];
        NSLog(@"2");
    }
}

/**
 *  返回三个数值，分别为三行的数值，如果有只有第一行的话，two和three数值为-1以此类推,从0开始。
 */
- (void)returnSelecteOneComponent : (NSInteger)oneComponent
                     TwoComponent : (NSInteger)twoComponent
                   ThreeComponent : (NSInteger)threeComponent
{
    NSLog(@"oneComponent : %ld\ntwoComponent : %ld\nthreeComponent : %ld",oneComponent,twoComponent,threeComponent);
}
/**
 *  返回选择了的三个数据,如果只有第一行的话，two和three数值为nil，以此类推
 */
- (void)returnSelecteOneString : (NSString *)oneString
                     TwoString : (NSString *)twoString
                   ThreeString : (NSString *)threeString
{
    NSLog(@"oneString : %@\ntwoString : %@\nthreeString : %@",oneString,twoString,threeString);
    self.lb_time.textColor = [UIColor redColor];
    self.lb_time.text = [NSString stringWithFormat:@"%@ %@ %@",oneString,twoString,threeString];
    self.lv_able.hidden = YES;
}
/**
 *  取消了选择
 */
- (void)cancelSelected
{
    NSLog(@"取消");
}




//添加pickerView
-(void)addPickerView{
    
    self.textField = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, 300, 30)];
    DDInputPickerView * inputView = [[DDInputPickerView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height / 3.0)];
    self.textField.userInteractionEnabled = YES;
    self.textField.hidden = YES;
    inputView.component = 3;
    inputView.isDynamic = YES;
    inputView.dataDict  = @{@" 今天":@{@"上午":@[
                                             @"8:00-9:00",
                                             @"9:00-10:00",
                                             @"10:00-11:00",
                                             @"11:00-12:00"
                                             ].mutableCopy,
                                     @"下午":@[
                                             @"2:00-3:00",
                                             @"3:00-4:00",
                                             @"4:00-5:00",
                                             @"5:00-6:00"
                                             ].mutableCopy,
                                     }.mutableCopy,
                            @" 明天":@{@"上午":@[
                                             @"8:00-9:00",
                                             @"9:00-10:00",
                                             @"10:00-11:00",
                                             @"11:00-12:00"
                                             ].mutableCopy,
                                     @"下午":@[
                                             @"2:00-3:00",
                                             @"3:00-4:00",
                                             @"4:00-5:00",
                                             @"5:00-6:00"
                                             ].mutableCopy,
                                     }.mutableCopy,
                            @" 后天":@{@"上午":@[
                                             @"8:00-9:00",
                                             @"9:00-10:00",
                                             @"10:00-11:00",
                                             @"11:00-12:00"
                                             ].mutableCopy,
                                     @"下午":@[
                                             @"2:00-3:00",
                                             @"3:00-4:00",
                                             @"4:00-5:00",
                                             @"5:00-6:00"
                                             ].mutableCopy,
                                     }.mutableCopy,
                            }.mutableCopy;
    /**
     inputView.dataArray = @[
     @[
     @"111",
     @"222",
     @"333"
     ].mutableCopy,
     @[
     @"aaa",
     @"bbb",
     @"ccc",
     @"ddd"
     ].mutableCopy,
     @[
     @"!!!",
     @"@@@"
     ].mutableCopy
     ].mutableCopy;
     */
    DDInputAccessoryPickerView * inputAccessoryPickerView = [[DDInputAccessoryPickerView alloc] initWithFrame:CGRectMake(0, 0, 0, 40)];
    [self.textField dd_KeyBoardPickerViewWithDelegate:self InputAccessoryView:inputAccessoryPickerView InputView:inputView];
    
    
    
    [self addSubview:self.textField];
}

@end
